// user.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const Task = require('./task');

const userSchema = new Schema({
 
   nickname:{type:String,require:false},
   phone:{type:String,require:false},
   personalSignature:{type:String,require:true,default:'系统原装签名，送给每一位无产阶级奋斗者'},
   email:{type:String,require:false},
   account: { type: String, required: true },
   avatar: { type: String },
   password: { type: String, required: true },
   department: [{
      departmentId: { type: Schema.Types.ObjectId, ref: 'Department' },
      jobTitle: String
    }],
   taskList: [Task.schema],
   role: { type: String, enum: ['admin', 'user'],required: true ,default: 'user' },
   createdAt: { type: Date, default: Date.now },
   updatedAt: { type: Date, default: Date.now },
});

const User = mongoose.model('User', userSchema);

module.exports = User;
